import request from '@/config/axios'

// 渠道活码相关接口

export interface ChannelQrcodeVO {
  pageNo?: number
  pageSize?: number
  qrcodeName?: string
  type?: number // 联系方式类型(1-单人,2-多人)
  state?: string // 企业自定义state参数
  skipVerify?: boolean // 是否自动通过好友(0-否,1-是)
  autoTag?: boolean // 是否自动打标签(0-否,1-是)
  autoRemark?: boolean // 是否自动备注(0-否,1-是)
  remarkContent?: any & {
    label?: string
    format: string
    addTime?: string
  } // 备注内容模板
  welcomeMsg?: string // 欢迎语内容
  status?: number // 状态(0-禁用,1-启用)
  createTime?: string
}

/**
 * 创建渠道活码
 */
export const createChannelQrcode = (data: any) => {
  return request.post({ url: '/crm/channel-qrcode/create', data })
}

/**
 * 更新渠道活码
 */
export const updateChannelQrcode = (data: any) => {
  return request.put({ url: '/crm/channel-qrcode/update', data })
}

/**
 * 删除渠道活码
 */
export const deleteChannelQrcode = (id: string) => {
  return request.delete({ url: '/crm/channel-qrcode/delete', params: { id } })
}

/**
 * 获得渠道活码
 */
export const getChannelQrcode = (id: string) => {
  return request.get({ url: '/crm/channel-qrcode/get', params: { id } })
}

/**
 * 获得渠道活码分页
 */
export const getChannelQrcodePage = (params: ChannelQrcodeVO) => {
  return request.get({ url: '/crm/channel-qrcode/page', params })
}

/**
 * 导出渠道活码 Excel
 */
export const exportChannelQrcodeExcel = (params: {
  pageNo?: number
  pageSize?: number
  qrcodeName?: string
  type?: string
  state?: string
  skipVerify?: string
  autoTag?: string
  autoRemark?: string
  remarkContent?: string
  welcomeMsg?: string
  status?: string
  createTime?: string
}) => {
  return request.download({ url: '/crm/channel-qrcode/export-excel', params })
}

/**
 * 获取配置了客户联系功能的成员列表
 */
export const getFollowUserList = () => {
  return request.get({ url: '/crm/wecom/server/getFollowUserList' })
}

/**
 * 获取企业已配置的「联系我」方式
 */
export const getContactWay = (configId: string) => {
  return request.get({ url: '/crm/wecom/server/getContactWay', params: { configId } })
}

/**
 * 获取企业标签列表
 */
export const getCorpTagList = (data?: { tagId?: string[]; groupId?: string[] }) => {
  return request.post({ url: '/crm/wecom/server/getCorpTagList', data })
}

/**
 * 获取配置了客户联系功能的成员列表
 */
export const listContactWay = (params?: {
  startTime?: number
  entTime?: number
  cursor?: string
  limit?: string
}) => {
  return request.get({ url: '/crm/wecom/server/listContactWay', params })
}
